package mrusanov.battle

import mrusanov.player.Player

object PlayerState {
  def apply(player:Player) = new PlayerState(player)
}

class PlayerState private (val player:Player) {
  require(player.team.isDefined, "Player must have team!")
  val team = player.team.get
  val playerType = player.playerType

  var hp = player.hp
  val damage = player.damage

  def alive = hp > 0

  def performAttack(enemy:PlayerState) {
    enemy.hp -= enemy.player.playerType.resistances.damageTaken(
      this.damage, this.player.playerType.damageType)
  }
}
